<?php

/**
 * This is the model class for table "jurnal_detail".
 *
 * The followings are the available columns in table 'jurnal_detail':
 * @property string $ID_DET_JURNAL
 * @property string $ID_JURNAL
 * @property integer $ITEM
 * @property string $ID_AKUN
 * @property integer $DEBIT_KREDIT
 * @property double $NILAI
 */
class JurnalDetail extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return JurnalDetail the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'jurnal_detail';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('DEBIT_KREDIT', 'required'),
			array('ITEM, DEBIT_KREDIT', 'numerical', 'integerOnly'=>true),
			array('NILAI', 'numerical'),
			array('ID_JURNAL, ID_AKUN', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID_DET_JURNAL, ID_JURNAL, ITEM, ID_AKUN, DEBIT_KREDIT, NILAI', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'master'=>array(self::BELONGS_TO, 'MasterAkun', 'ID_AKUN'),
			'jurnal'=>array(self::BELONGS_TO, 'Jurnal', 'ID_JURNAL'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID_DET_JURNAL' => 'Id Det Jurnal',
			'ID_JURNAL' => 'Id Jurnal',
			'ITEM' => 'Item',
			'ID_AKUN' => 'Id Akun',
			'DEBIT_KREDIT' => 'Debit Kredit',
			'NILAI' => 'Nilai',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID_DET_JURNAL',$this->ID_DET_JURNAL,true);
		$criteria->compare('ID_JURNAL',$this->ID_JURNAL,true);
		$criteria->compare('ITEM',$this->ITEM);
		$criteria->compare('ID_AKUN',$this->ID_AKUN,true);
		$criteria->compare('DEBIT_KREDIT',$this->DEBIT_KREDIT);
		$criteria->compare('NILAI',$this->NILAI);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}